<template>
  <div class="EmployeeDetails">
    <!-- 头部 -->
    <div class="Title">
      <div class="blue"></div>
      <span class="title">生产编辑</span>
      <el-button
        class="right-box"
        type="info"
        icon="el-icon-back"
        onclick="window.history.go(-1)"
      >返回</el-button>
    </div>
    <div class="plan">
      <div class="contents" :v-model="allName">
        <div class="content_plan">
          <div class="department">
            <span>计划年份</span>
            <el-input class="deparInput" v-model="allName.pyear"></el-input>
          </div>
          <div class="department">
            <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;月份</span>
            <el-input class="deparInput" v-model="allName.pmonth"></el-input>
          </div>
        </div>
        <div class="content_plans">
          <div class="department">
            <span>产品编号</span>
            <el-input class="deparInput" v-model="allName.productno"></el-input>
          </div>
          <div class="department">
            <span>产品名称</span>
            <el-input class="deparInput" v-model="allName.productname"></el-input>
          </div>
          <div class="department">
            <span>产品类型</span>
            <el-input class="deparInput" v-model="allName.productype"></el-input>
          </div>
          <div class="department">
            <span>计划时间</span>
            <el-input class="deparInput" v-model="allName.planon"></el-input>
          </div>
          <div class="department">
            <span>结束时间</span>
            <el-input class="deparInput" v-model="allName.endon"></el-input>
          </div>
          <div class="department">
            <span>需求数量</span>
            <el-input class="deparInput" v-model="allName.total"></el-input>
          </div>
        </div>
        <div class="content_list">
          <p class="Headline">原料需求</p>
          <template>
            <el-table :data="tableDataline" :max-height="200" style="width: 100%">
              <el-table-column prop="xuhao" type="index" label="序号" align="center"></el-table-column>
              <el-table-column prop="rawname" label="原料名称" align="center"></el-table-column>
              <el-table-column prop="rawtype" label="原料类型" align="center"></el-table-column>
              <el-table-column prop="guige" label="规格" align="center"></el-table-column>
              <el-table-column prop="need" label="需求数量" align="center"></el-table-column>
              <el-table-column prop="inventory" label="库存数量" align="center"></el-table-column>
            </el-table>
          </template>
          <div class="Btn">
            <el-button type="primary" @click="tiaozSure">确认</el-button>
            <el-button type="info" onclick="window.history.go(-1)">返回</el-button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import axios from "axios";
export default {
  data() {
    return {
      form: {},
      allName: {},
      Detail: "",
      tableDataline: []
    };
  },
  created() {
    this.allName = this.$route.query.name;
    console.log(this.allName);
    this.Detail = this.allName.productno;
    this.geiApply();
  },
  methods: {
    geiApply() {
      axios(
        "/apis/ProductionManagement.asmx/Det?index=2&jsondata=" + this.Detail
      ).then(({ data }) => {
        var datas = this.$x2js.xml2js(data);
        console.log("详情");
        console.log(datas);
        var list = JSON.parse(datas.string.__text);
        console.log(list);
        this.tableDataline = list.sour;
      });
    },
    // 调整确认按钮
    tiaozSure() {
      var obj = {
        pyear: this.allName.pyear,
        pmonth: this.allName.pmonth,
        productno: this.allName.productno,
        planon: this.allName.planon,
        endon: this.allName.endon,
        total: this.allName.total
      };
      var objs = JSON.stringify(obj);
      axios(
        "/apis/ProductionManagement.asmx/Save?index=2&jsondata=" + objs
      ).then(({ data }) => {
        var datas = this.$x2js.xml2js(data);
        if (datas.string.__text == "SUCCESS") {
            this.$message.success("保存成功");
            window.history.go(-1);
          } 
      });
    }
  }
};
</script>

<style lang="scss" scoped>
@import "@/assets/scss/base.scss";
.EmployeeDetails {
  width: 99%;
}
.Title {
  width: 99%;
  height: 35px;
  margin-top: 10px;
}
.blue {
  width: 5px;
  height: 20px;
  background-color: $Header_color;
  margin-left: 20px;
  margin-top: 5px;
  float: left;
}
.title {
  margin-left: 10px;
  line-height: 35px;
}
.right-box {
  float: right;
  margin-right: 2%;
  border-radius: 5px;
}
.plan {
  width: 99%;
  height: 100%;
  margin-left: 15px;
  margin-top: 10px;
  height: 700px;
  background-color: white;
  border: 1px solid rgb(247, 243, 243);
}
.content_plan {
  width: 99%;
  margin-top: 20px;
  //    border: 1px solid #000;
}
.department {
  width: 30%;
  height: 50px;
  margin-left: 15px;
  //   border: 1px solid #000;
  display: inline-block;
}

.deparInput {
  width: 60%;
  margin-top: 5px;
}
.content_list {
  width: 86%;
  margin-left: 15px;
  //   text-align: center;
}
.Btn {
  text-align: center;
  margin-top: 20px;
  // border: 1px solid #000;
}
.Headline {
  font-size: 14px;
  height: 40px;
  line-height: 40px;
  font-weight: 700;
  color: $fontcolor;
  padding-left: 15px;
  border-bottom: 1px solid $linecolor;
}
</style>